<template>
  <div class="topblock-container">
    <div class="topblock-row">
      <div class="pic" v-if="seller">
        <img :src="seller.avatar" alt="">
      </div>
      <div class="msg" v-if="seller">
        <div class="title"><img src="../resource/img/brand@2x.png" alt="品牌"><span>{{ seller.name }}</span></div>
        <div class="transport"><span>{{ seller.description }}/{{ seller.deliveryTime }}分钟送达</span></div>
        <div class="pay"><img src="../resource/img/decrease_1@3x.png" alt="减"><span v-if="seller.supports">{{
            seller.supports[0].description }}</span><label @click="showNotice"><span class="discount">5个</span><i class="icon-keyboard_arrow_right"></i></label></div>
      </div>
    </div>
    <div class="noticeblock-container" @click="showNotice">
      <img src="../resource/img/bulletin@3x.png" alt="公告">
      <span v-if="seller">{{ seller.bulletin }}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" alt="">
    </div>
  </div>
</template>

<script>
const ERR_OK = 0
export default {
  name: 'TopBlock',
  data () {
    return {
      seller: []
    }
  },
  created () {
    this.getInfo()
  },
  methods: {
    getInfo () {
      this.$http.get('http://localhost:8081/api/seller').then(res => {
        // console.log(res.body.errno)
        // 异步请求数据，渲染界面要先v-if判断是否有数据嘞
        if (res.body.errno !== ERR_OK) return
        this.seller = res.body.data
      })
    },
    showNotice () {
      this.$emit('appfunc')
    }
  }
}

</script>

<style lang="scss" scoped>
  .topblock-container {
    width: 100%;
    height: 2.68rem;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;

    .topblock-row {
      padding: 0.48rem 0.24rem 0.36rem 0.48rem;
      display: flex;
      justify-content: unset;
      align-items: center;
      width: 100%;
      height: 2.12rem;
      background-color: rgba(7, 17, 27, 0.5);

      .pic {
        width: 1.28rem;
        height: 1.28rem;

        img {
          width: 1.28rem;
          height: 1.28rem;
          border-radius: 2px;
        }
      }

      .msg {
        width: 100%;
        height: 100%;
        padding-left: 0.32rem;

        .title {
          height: 0.44rem;
          color: #fff;

          img {
            display: inline-block;
            width: 0.6rem;
            height: 0.36rem;
            font-size: 0;
            margin-right: 0.12rem;
            vertical-align: middle;
          }

          span {
            line-height: 0.44rem;
            font-size: 0.30rem;
            font-weight: bold;
            vertical-align: middle;
          }

        }

        .transport {

          span {
            height: 0.48rem;
            line-height: 0.48rem;
            color: #fff;
            font-size: 0.24rem;
            font-weight: 200;
          }
        }

        .pay {

          height: 0.28rem;
          line-height: 0.28rem;
          font-size: 0.24rem;
          color: #fff;
          font-weight: 200;
          position: relative;

          img {
            display: inline-block;
            width: 0.36rem;
            height: 0.36rem;
            margin-right: 0.08rem;
            font-size: 0;
            vertical-align: middle;
          }

          span {
            vertical-align: middle;
          }

          .discount {
            position: absolute;
            top: -0.1rem;
            right: 0;
            height: 0.48rem;
            line-height: 0.48rem;
            width: 1rem;
            text-align: center;
            background-color: rgba(0, 0, 0, .2);
            border-radius: 25px;
          }

          .icon-keyboard_arrow_right {
            font-size: 0.28rem;
            position: absolute;
            right: 0.05rem;
          }
        }
      }

    }

    .noticeblock-container {
      padding: 0 0.24rem;
      width: 100%;
      height: 0.56rem;
      color: #fff;
      background-color: rgba(7, 17, 27, 0.7);
      // filter: blur(10px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      position: relative;

      img {
        display: inline-block;
        width: 0.66rem;
        height: 0.36rem;
        vertical-align: middle;
        font-size: 0;
      }

      span {
        padding-left: 0.08rem;
        width: 100%;
        line-height: 0.56rem;
        font-size: 0.28rem;
        font-weight: 200;
        vertical-align: middle;
      }

      .icon-keyboard_arrow_right {
        font-size: 0.56rem;
        position: absolute;
        top: 0;
        right: 0;
      }

    }

    .background {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      z-index: -1;

      img {
        width: 100%;
        height: 100%;
        filter: blur(10px)
      }
    }

  }

</style>
